package front

import (
	"hft/Http/Services/front"
	utils "hft/Http/Utils"
	"strconv"

	"github.com/gin-gonic/gin"
)

type Region struct{}

func (*Region) FindRegion(c *gin.Context) {

	id := c.Request.Header.Get("sid")

	newId, err := strconv.Atoi(id)

	if err != nil {
		utils.FailWithMessage("未知错误500", c)
		return
	}

	list, err := front.RegionService.FindRegion(newId)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.OkWithData(list, c)
}

var RegionController = new(Region)
